import vTebs from "./v-tebs";
import { getshlist, gettdtList } from "../utils/api";

export default {
    install(Vue) {
        let webGis = null;
        Vue.prototype.gisInit = function (data) {
            webGis = data;
            window.Viewer = webGis._Viewer;
            //光照阴影
            window.Viewer.scene.globe.enableLighting = false;
            window.Viewer.shadows = false;
            //深度检测
            webGis.Analysis.depthTestAgainstTerrain(true);
            //加载TMS影像服务
            var viewerLayers = window.Viewer.imageryLayers;
            var tmslayer = new Cesium.UrlTemplateImageryProvider({
                url: window.conf.tmsurl,
            });
            viewerLayers.addImageryProvider(tmslayer);

            //加载倾斜模型
            window.qingxie = new Cesium.Cesium3DTileset({
                url: window.conf.qxmodelurl,
            });
            qingxie.readyPromise
                .then(function (tileset) {
                    // 调整三维模型高度
                    let cartographic = window.Cesium.Cartographic.fromCartesian(
                        tileset.boundingSphere.center
                    );
                    let surface = window.Cesium.Cartesian3.fromRadians(
                        cartographic.longitude,
                        cartographic.latitude,
                        0
                    );
                    let offset = window.Cesium.Cartesian3.fromRadians(
                        cartographic.longitude,
                        cartographic.latitude,
                        -120
                    );
                    let translation = window.Cesium.Cartesian3.subtract(
                        offset,
                        surface,
                        new window.Cesium.Cartesian3()
                    );
                    tileset.modelMatrix = window.Cesium.Matrix4.fromTranslation(
                        translation
                    );
                    window.Viewer.flyTo(tileset, {
                        duration: 0.1,
                    });
                })
                .otherwise(function (error) {
                    console.log(error);
                });
            window.Viewer.scene.primitives.add(qingxie);

            //加载geojson
            var promise = Cesium.GeoJsonDataSource.load(
                window.conf.geojsonurl
            );
            promise.then(function (dataSource) {
                window.Viewer.dataSources.add(dataSource);
                var entities = dataSource.entities.values;
                for (var i = 0; i < entities.length; i++) {
                    var entity = entities[i];
                    var tempentity = window.Viewer.entities.add({
                        id: entity.properties.buildid.getValue().toString(),
                        position: Cesium.Cartesian3.fromDegrees(
                            entity.properties.lon.getValue(), entity.properties.lat.getValue(),
                            10
                        ),
                        polygon: {
                            hierarchy: entity.polygon.hierarchy,
                            material: Cesium.Color.GHOSTWHITE.withAlpha(0),
                            outline: true,
                            height: undefined,
                            heightReference: 1,
                            extrudedHeight: undefined
                        }
                    });
                    tempentity.lon = entity.properties.lon.getValue();
                    tempentity.lat = entity.properties.lat.getValue();
                }
                window.Viewer.dataSources.removeAll();
            });

            //拾取点击事件
            const handlerIcon = new Cesium.ScreenSpaceEventHandler(
                window.Viewer.scene.canvas
            );
            const zuobs = [];
            handlerIcon.setInputAction(function (click) {
                //输出坐标
                const pos = window.Viewer.scene.pickPosition(click.position);
                if (pos) {
                    var cartographic = Cesium.Cartographic.fromCartesian(pos);
                    let zuob = [];
                    let x = Cesium.Math.toDegrees(cartographic.longitude);
                    zuob.push(x);
                    let y = Cesium.Math.toDegrees(cartographic.latitude);
                    zuob.push(y);
                    zuobs.push(zuob);
                    console.log(zuob);
                }
                //消除上次点击的状态
                if (window.highentity) {
                    window.highentity.polygon.material = Cesium.Color.GHOSTWHITE.withAlpha(0);
                    window.highentity = undefined;
                }
                //识别矢量面
                const picks = window.Viewer.scene.drillPick(click.position);
                for (let i = 0; i < picks.length; i++) {
                    let element = picks[i];
                    //弹建筑信息窗口并高亮2
                    if (element && element.id && element.id.id && Vue.prototype.index == 2) {
                        window.highentity = window.Viewer.entities.getById(element.id.id);
                        window.highentity.polygon.material = Cesium.Color.CRIMSON.withAlpha(0.5);
                        window.residentInit(element.id.id);
                        break;
                    }
                    //弹网格信息窗
                    if (element && element.id && element.id.id && Vue.prototype.index == 21) {
                        var orgCode = element.id.id;
                        var gridname = element.id.gridname;
                        var gridaddress = element.id.gridaddress;
                        // yhadd 
                        window._yhGirdLayer(orgCode, gridname, gridaddress)
                        break;
                    }
                    //弹重点项目窗口3
                    if (element && element.id && Vue.prototype.index == 3) {
                        window.imporLayerInit(element.id.name);
                        break;
                    }
                    //弹力量排布窗口1
                    if (element && element.id && Vue.prototype.index == 1) {
                        if (element.id.id == 'zfy1') {
                            window._yhZfyInit();
                        }
                    }
                    //弹工商检查窗口0
                    if (element && element.id && Vue.prototype.index == 0) {
                        window.gsjcLayerInit(element.id.tyshxydm);
                        break;
                    }
                    //弹智慧门牌窗口4
                    if (element && element.id && Vue.prototype.index == 4) {
                        window.zhmpLayerInit(element.id.id);
                        break;
                    }
                }
            }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
        }
        // if (!Cesium.PolylineTrailLinkMaterialProperty) {

        //     /*
        //        流纹纹理线
        //        color 颜色
        //        duration 持续时间 毫秒
        //     */
        //     function PolylineTrailLinkMaterialProperty(color, Line, duration) {
        //         this._definitionChanged = new Cesium.Event();
        //         this._color = undefined;
        //         this._colorSubscription = undefined;
        //         this.color = color;
        //         this._Line = Line;
        //         this.duration = duration;
        //         this._time = (new Date()).getTime();
        //     }

        //     Object.defineProperties(PolylineTrailLinkMaterialProperty.prototype, {
        //         isConstant: {
        //             get: function () {
        //                 return false;
        //             }
        //         },
        //         definitionChanged: {
        //             get: function () {
        //                 return this._definitionChanged;
        //             }
        //         },
        //         color: Cesium.createPropertyDescriptor('color')
        //     });
        //     PolylineTrailLinkMaterialProperty.prototype.getType = function (time) {
        //         return 'PolylineTrailLink';
        //     }
        //     PolylineTrailLinkMaterialProperty.prototype.setScale = function (scale) {
        //         this.scale = scale;
        //     }
        //     PolylineTrailLinkMaterialProperty.prototype.getValue = function (time, result) {
        //         if (!Cesium.defined(result)) {
        //             result = {};
        //         }
        //         result.color = Cesium.Property.getValueOrClonedDefault(this._color, time, Cesium.Color.WHITE, result.color);
        //         if (typeof this._Line === 'object') {
        //             if (this._Line.LightSpot) {
        //                 result.lightSpot = true;
        //                 result.lightSpotColor = this._Line.color;
        //             } else {
        //                 result.color1 = this._Line.color1;
        //                 result.color2 = this._Line.color2;
        //                 result.twoColor = true;
        //             }
        //         } else {
        //             result.image = this._Line;
        //         }
        //         if (this.scale !== undefined) {
        //             result.time = this.scale;
        //         } else {
        //             result.time = (((new Date()).getTime() - this._time) % this.duration) / this.duration;
        //         }
        //         return result;
        //     }
        //     PolylineTrailLinkMaterialProperty.prototype.equals = function (other) {
        //         return this === other ||
        //             (other instanceof PolylineTrailLinkMaterialProperty &&
        //                 Cesium.Property.equals(this._color, other._color))
        //     }
        //     Cesium.PolylineTrailLinkMaterialProperty = PolylineTrailLinkMaterialProperty;
        //     Cesium.Material.PolylineTrailLinkType = 'PolylineTrailLink';
        //     Cesium.Material.PolylineTrailLinkImage = 'static/img/gsyj.png';
        //     Cesium.Material.PolylineTrailLinkSource = "czm_material czm_getMaterial(czm_materialInput materialInput)\n\
        //                                               {\n\
        //                                                    czm_material material = czm_getDefaultMaterial(materialInput);\n\
        //                                                    vec2 st = materialInput.st;\n\
        //                                                    if(twoColor){\n\
        //                                                     if(st.s<time){\n\
        //                                                         material.alpha = color1.a;\n\
        //                                                         material.diffuse = color1.rgb;\n\
        //                                                     }else{\n\
        //                                                         material.alpha = color2.a;\n\
        //                                                         material.diffuse = color2.rgb;\n\
        //                                                     }\n\
        //                                                    }else if(lightSpot){\n\
        //                                                     if(st.s<time){\n\
        //                                                         material.alpha = pow(st.s / time, 20.0);\n\
        //                                                         if(material.alpha<0.3){\n\
        //                                                             material.alpha = 0.3;\n\
        //                                                             material.diffuse = color.rgb;\n\
        //                                                         }else{\n\
        //                                                             material.diffuse = lightSpotColor.rgb;\n\
        //                                                         }\n\
        //                                                     }else{\n\
        //                                                         material.alpha = 0.3;\n\
        //                                                         material.diffuse = color.rgb;\n\
        //                                                     }\n\
        //                                                    }else{\n\
        //                                                     vec4 colorImage = texture2D(image, vec2(fract(st.s - time), st.t));\n\
        //                                                     material.alpha = colorImage.a * color.a;\n\
        //                                                     material.diffuse = (colorImage.rgb+color.rgb)/2.0;\n\
        //                                                    }\n\
        //                                                    return material;\n\
        //                                                }";
        //     Cesium.Material._materialCache.addMaterial(Cesium.Material.PolylineTrailLinkType, {
        //         fabric: {
        //             type: Cesium.Material.PolylineTrailLinkType,
        //             uniforms: {
        //                 color: new Cesium.Color(1.0, 0.0, 0.0, 0.5),
        //                 color1: new Cesium.Color(0.0, 1.0, 0.0, 0.5),
        //                 color2: new Cesium.Color(1.0, 0.0, 0.0, 0.5),
        //                 image: Cesium.Material.PolylineTrailLinkImage,
        //                 twoColor: false,
        //                 lightSpot: false,
        //                 lightSpotColor: new Cesium.Color(1.0, 1.0, 1.0, 0.5),
        //                 time: 0
        //             },
        //             source: Cesium.Material.PolylineTrailLinkSource
        //         },
        //         translucent: function (material) {
        //             return true;
        //         }
        //     });
        // }


        //随机颜色
        function getRandomColor() {
            return '#' + (function (h) {

                return new Array(7 - h.length).join("0") + h

            })((Math.random() * 0x1000000 << 0).toString(16))
        }
        //网格渲染
        Vue.prototype.wgInit = function () {
            //切换视角
            window.Viewer.camera.setView({
                destination : {x: -2706803.1138180005, y: 4891354.5177578125, z: 3064022.695832984},
                orientation: {
                    heading : 2.154516476104762, // east, default value is 0.0 (north)
                    pitch : -0.45698903811647096,    // default value (looking down)
                    roll : 0.002635094703036245                             // default value
                }
            });

            Vue.prototype.index = 21;
            gettdtList().then((res) => {
                if (res.data.status == 200) {
                    var wglist = res.data.data;
                    //wgid数组
                    var wgidarr = [];
                    for (let i = 0; i < wglist.length; i++) {
                        //剔除第一个全部的
                        if (i == 0) {
                            continue;
                        }
                        //加网格
                        var wgid = wglist[i][5];
                        var gridaddress = wglist[i][0];
                        var namelist = wglist[i][0].split(">");
                        var wgname = namelist[namelist.length - 1];
                        var lon = wglist[i][1];
                        var lat = wglist[i][3];
                        var lonlatlist = wglist[i][4].split(",");
                        var geometry = [];
                        var linepositions = [];
                        for (let j = 0; j < lonlatlist.length; j++) {
                            geometry.push(lonlatlist[j].split(" ")[0]);
                            geometry.push(lonlatlist[j].split(" ")[1]);
                            // geometry.push(20);
                            let a = Cesium.Cartesian3.fromDegrees(
                                lonlatlist[j].split(" ")[0], lonlatlist[j].split(" ")[1]
                            );
                            linepositions.push(a);
                        }
                        var hierarchy = Cesium.Cartesian3.fromDegreesArray(geometry);
                        wgidarr.push(wgid);
                        var tempwg = window.Viewer.entities.add({
                            id: wgid,
                            name: wgname,
                            position: Cesium.Cartesian3.fromDegrees(
                                lon, lat,
                                0
                            ),
                            polygon: {
                                hierarchy: new Cesium.PolygonHierarchy(hierarchy),
                                material: Cesium.Color.fromCssColorString(getRandomColor()).withAlpha(0.2),
                                // perPositionHeight: false,
                                outline: true,
                                outlineWidth: 1,
                                outlineColor: Cesium.Color.NAVY,
                                height: undefined,
                                heightReference: 1,
                                extrudedHeight: undefined
                            },
                            polyline: {
                                clampToGround: true,
                                positions: linepositions,
                                // material: new Cesium.Color.fromCssColorString("#FFD700"),                     
                                width: 5,
                                material: new Cesium.PolylineGlowMaterialProperty({
                                    glowPower: 0.5,
                                    color: Cesium.Color.CHARTREUSE
                                })
                            },
                            label: {
                                text: wgname,
                                font: '20px Source Han Sans CN',
                                fillColor: Cesium.Color.BLACK,        //字体颜色
                                backgroundColor: Cesium.Color.GREENYELLOW,    //背景颜色
                                showBackground: true,                //是否显示背景颜色
                                style: Cesium.LabelStyle.FILL,        //label样式
                                pixelOffset: new Cesium.Cartesian2(0, -70),
                                scaleByDistance: new Cesium.NearFarScalar(0, 2, 12500, 0)
                            },
                        });
                        tempwg.gridname = wgname;
                        tempwg.gridaddress = gridaddress;
                    }
                    Vue.prototype.wgidarr = wgidarr;
                }
            });
        }
        //网格清除
        Vue.prototype.wgclear = function () {
            Vue.prototype.index = 2;
            var wgidarr = Vue.prototype.wgidarr;
            for (var i = 0; i < wgidarr.length; i++) {
                window.Viewer.entities.removeById(wgidarr[i]);
            }
        }
        //重点项目
        Vue.prototype.impor = function () {
            //1.体育公园
            var geometry1 = [
                118.97977890022686, 28.876902299875876, 10,
                118.97973768654997, 28.87653985367143, 10,
                118.9789356646143, 28.876577275759658, 10,
                118.97894997173383, 28.87693686668845, 10
            ];
            var hierarchy1 = Cesium.Cartesian3.fromDegreesArrayHeights(geometry1);
            window.Viewer.entities.add({
                id: "z1",
                name: "体育公园",
                position: Cesium.Cartesian3.fromDegrees(
                    118.97934851058773, 28.876731129708013,
                    0
                ),
                polygon: {
                    hierarchy: new Cesium.PolygonHierarchy(hierarchy1),
                    material: Cesium.Color.ROYALBLUE.withAlpha(0.5),
                    heightReference: 0,
                    outline: true,
                    outlineWidth: 1,
                    outlineColor: Cesium.Color.NAVY,
                },
                // billboard: {
                //     image: require("@/assets/image/zdxmimg/体育公园.jpg"),
                //     width: 600,
                //     height: 378,
                //     disableDepthTestDistance: Number.POSITIVE_INFINITY,
                //     scaleByDistance: new Cesium.NearFarScalar(0, 1, 2500, 0),
                // },
                label: {
                    text: "体育公园",
                    font: '20px Source Han Sans CN',
                    fillColor: Cesium.Color.BLACK,        //字体颜色
                    backgroundColor: Cesium.Color.VIOLET,    //背景颜色
                    showBackground: true,                //是否显示背景颜色
                    style: Cesium.LabelStyle.FILL,        //label样式
                    pixelOffset: new Cesium.Cartesian2(0, -70),
                    scaleByDistance: new Cesium.NearFarScalar(0, 2, 12500, 0)
                },
            });
            //2.小镇客厅
            var geometry2 = [
                118.97655925747041, 28.873168436882885, 10,
                118.97689056876452, 28.872802076392414, 10,
                118.97702134597071, 28.87317496529229, 10,
                118.97692636388457, 28.873381938012184, 10,
                118.9767243939505, 28.873342512323074, 10
            ];
            var hierarchy2 = Cesium.Cartesian3.fromDegreesArrayHeights(geometry2);
            window.Viewer.entities.add({
                id: "z2",
                name: "小镇客厅",
                position: Cesium.Cartesian3.fromDegrees(
                    118.97681793284278, 28.873115705071335,
                    0
                ),
                polygon: {
                    hierarchy: new Cesium.PolygonHierarchy(hierarchy2),
                    material: Cesium.Color.ROYALBLUE.withAlpha(0.5),
                    heightReference: 0,
                    outline: true,
                    outlineWidth: 1,
                    outlineColor: Cesium.Color.NAVY,
                },
                // billboard: {
                //     image: require("@/assets/image/zdxmimg/小镇客厅.jpg"),
                //     width: 600,
                //     height: 378,
                //     disableDepthTestDistance: Number.POSITIVE_INFINITY,
                //     scaleByDistance: new Cesium.NearFarScalar(0, 1, 2500, 0),
                // },
                label: {
                    text: "小镇客厅",
                    font: '20px Source Han Sans CN',
                    fillColor: Cesium.Color.BLACK,        //字体颜色
                    backgroundColor: Cesium.Color.VIOLET,    //背景颜色
                    showBackground: true,                //是否显示背景颜色
                    style: Cesium.LabelStyle.FILL,        //label样式
                    pixelOffset: new Cesium.Cartesian2(0, -70),
                    scaleByDistance: new Cesium.NearFarScalar(0, 2, 12500, 0)
                },
            });
            //3.未来社区
            var geometry3 = [
                118.97890856954588, 28.87566815638317, 10,
                118.97975250010316, 28.87556979644153, 10,
                118.98006380680444, 28.874559315110996, 10,
                118.97896450381613, 28.874600027910596, 10
            ];
            var hierarchy3 = Cesium.Cartesian3.fromDegreesArrayHeights(geometry3);
            window.Viewer.entities.add({
                id: "z3",
                name: "未来社区",
                position: Cesium.Cartesian3.fromDegrees(
                    118.97929670352495, 28.875078311534093,
                    0
                ),
                polygon: {
                    hierarchy: new Cesium.PolygonHierarchy(hierarchy3),
                    material: Cesium.Color.ROYALBLUE.withAlpha(0.5),
                    heightReference: 0,
                    outline: true,
                    outlineWidth: 1,
                    outlineColor: Cesium.Color.NAVY,
                },
                label: {
                    text: "未来社区",
                    font: '20px Source Han Sans CN',
                    fillColor: Cesium.Color.BLACK,        //字体颜色
                    backgroundColor: Cesium.Color.VIOLET,    //背景颜色
                    showBackground: true,                //是否显示背景颜色
                    style: Cesium.LabelStyle.FILL,        //label样式
                    pixelOffset: new Cesium.Cartesian2(0, -70),
                    scaleByDistance: new Cesium.NearFarScalar(0, 2, 12500, 0)
                },
            });
            //4.东岳村“改村提升”新村农户安置项目
            var geometry4 = [
                118.98002819710008, 28.877725978894336, 10,
                118.98143267092803, 28.878164288738013, 10,
                118.98147049748488, 28.877166666054766, 10,
                118.97997434272816, 28.876891416889016, 10
            ];
            var hierarchy4 = Cesium.Cartesian3.fromDegreesArrayHeights(geometry4);
            window.Viewer.entities.add({
                id: "z4",
                name: "东岳村“改村提升”新村农户安置项目",
                position: Cesium.Cartesian3.fromDegrees(
                    118.98072813101606, 28.877438474417406,
                    0
                ),
                polygon: {
                    hierarchy: new Cesium.PolygonHierarchy(hierarchy4),
                    material: Cesium.Color.ROYALBLUE.withAlpha(0.5),
                    heightReference: 0,
                    outline: true,
                    outlineWidth: 1,
                    outlineColor: Cesium.Color.NAVY,
                },
                label: {
                    text: "东岳村“改村提升”新村农户安置项目",
                    font: '20px Source Han Sans CN',
                    fillColor: Cesium.Color.BLACK,        //字体颜色
                    backgroundColor: Cesium.Color.VIOLET,    //背景颜色
                    showBackground: true,                //是否显示背景颜色
                    style: Cesium.LabelStyle.FILL,        //label样式
                    pixelOffset: new Cesium.Cartesian2(0, -70),
                    scaleByDistance: new Cesium.NearFarScalar(0, 2, 12500, 0)
                },
            });
        }
        //清除重点项目
        Vue.prototype.clearimpor = function () {
            window.Viewer.entities.removeById("z1");
            window.Viewer.entities.removeById("z2");
            window.Viewer.entities.removeById("z3");
            window.Viewer.entities.removeById("z4");
        }

        //工商检查分布
        Vue.prototype.gsjcinit = function () {
            //获取所有商户
            getshlist().then((res) => {
                if (res.data.code === 200) {
                    var shlist = res.data.data;
                    for (var i = 0; i < shlist.length; i++) {
                        if (shlist[i].tyshxydm == "92330803MA2FUMR77F") {
                            var entity = window.Viewer.entities.getById(shlist[i].gridid);
                            entity.billboard = new Cesium.BillboardGraphics({
                                image: "static/img/gsyj.png",
                                width: 88,
                                height: 122,
                                disableDepthTestDistance: Number.POSITIVE_INFINITY,
                                scaleByDistance: new Cesium.NearFarScalar(0, 1, 5000, 0)
                            });
                            entity.tyshxydm = shlist[i].tyshxydm;
                        } else {
                            if (i % 4 == 1) {
                                var entity = window.Viewer.entities.getById(shlist[i].gridid);
                                entity.billboard = new Cesium.BillboardGraphics({
                                    image: "static/img/xczf_1.png",
                                    width: 86,
                                    height: 121,
                                    disableDepthTestDistance: Number.POSITIVE_INFINITY,
                                    scaleByDistance: new Cesium.NearFarScalar(0, 1, 5000, 0)
                                });
                                entity.polygon.material = Cesium.Color.CRIMSON.withAlpha(0.5);
                                entity.tyshxydm = shlist[i].tyshxydm;
                            } else if (i % 4 == 2) {
                                var entity = window.Viewer.entities.getById(shlist[i].gridid);
                                entity.billboard = new Cesium.BillboardGraphics({
                                    image: "static/img/xczf_2.png",
                                    width: 86,
                                    height: 121,
                                    disableDepthTestDistance: Number.POSITIVE_INFINITY,
                                    scaleByDistance: new Cesium.NearFarScalar(0, 1, 5000, 0)
                                });
                                entity.polygon.material = Cesium.Color.GOLD.withAlpha(0.5);
                                entity.tyshxydm = shlist[i].tyshxydm;
                            } else if (i % 4 == 3) {
                                var entity = window.Viewer.entities.getById(shlist[i].gridid);
                                entity.billboard = new Cesium.BillboardGraphics({
                                    image: "static/img/xczf_3.png",
                                    width: 86,
                                    height: 121,
                                    disableDepthTestDistance: Number.POSITIVE_INFINITY,
                                    scaleByDistance: new Cesium.NearFarScalar(0, 1, 5000, 0)
                                });
                                entity.polygon.material = Cesium.Color.GREEN.withAlpha(0.5);
                                entity.tyshxydm = shlist[i].tyshxydm;
                            } else {
                                var entity = window.Viewer.entities.getById(shlist[i].gridid);
                                entity.billboard = new Cesium.BillboardGraphics({
                                    image: "static/img/xczf_4.png",
                                    width: 86,
                                    height: 121,
                                    disableDepthTestDistance: Number.POSITIVE_INFINITY,
                                    scaleByDistance: new Cesium.NearFarScalar(0, 1, 5000, 0)
                                });
                                entity.polygon.material = Cesium.Color.GREY.withAlpha(0.5);
                                entity.tyshxydm = shlist[i].tyshxydm;
                            }
                        }
                    }
                }
            });
        }

        //清除工商检查分布
        Vue.prototype.gsjcclear = function () {
            //获取所有商户
            getshlist().then((res) => {
                if (res.data.code === 200) {
                    var shlist = res.data.data;
                    for (var i = 0; i < shlist.length; i++) {
                        var entity = window.Viewer.entities.getById(shlist[i].gridid);
                        entity.billboard = undefined;
                        entity.polygon.material = Cesium.Color.GHOSTWHITE.withAlpha(0);
                    }
                }
            });
        }

        //力量排布分布
        //执法仪开关
        Vue.prototype.zfyinit = function () {
            //执法记录仪
            window.Viewer.entities.add({
                id: "zfy1",
                position: Cesium.Cartesian3.fromDegrees(
                    118.97890856954588, 28.87566815638317,
                    10
                ),
                billboard: {
                    image: require("@/assets/image/gsjcimg/执法记录.png"),
                    width: 89,
                    height: 151,
                    disableDepthTestDistance: Number.POSITIVE_INFINITY,
                    scaleByDistance: new Cesium.NearFarScalar(0, 1, 5000, 0)
                }
            });
        }
        Vue.prototype.zfyclear = function () {
            window.Viewer.entities.removeById("zfy1");
        }
        //摄像头开关
        Vue.prototype.sxtinit = function () {
            //摄像头
            window.Viewer.entities.add({
                id: "sxt1",
                position: Cesium.Cartesian3.fromDegrees(
                    118.97929670352495, 28.875078311534093,
                    10
                ),
                billboard: {
                    image: require("@/assets/image/gsjcimg/摄像头.png"),
                    width: 89,
                    height: 151,
                    disableDepthTestDistance: Number.POSITIVE_INFINITY,
                    scaleByDistance: new Cesium.NearFarScalar(0, 1, 5000, 0)
                }
            });
        }
        Vue.prototype.sxtclear = function () {
            window.Viewer.entities.removeById("sxt1");
        }
        //人员手环开关
        Vue.prototype.ryinit = function () {
            //人员手环
            window.Viewer.entities.add({
                id: "ry1",
                position: Cesium.Cartesian3.fromDegrees(
                    118.97692636388457, 28.873381938012184,
                    10
                ),
                billboard: {
                    image: require("@/assets/image/gsjcimg/人员.png"),
                    width: 89,
                    height: 151,
                    disableDepthTestDistance: Number.POSITIVE_INFINITY,
                    scaleByDistance: new Cesium.NearFarScalar(0, 1, 5000, 0)
                }
            });
        }
        Vue.prototype.ryclear = function () {
            window.Viewer.entities.removeById("ry1");
        }

        //智慧门牌分布
        Vue.prototype.zhmpinit = function () {
            //党员
            window.Viewer.entities.add({
                id: "fh1",
                position: Cesium.Cartesian3.fromDegrees(
                    118.97890856954588, 28.87066815638317,
                    10
                ),
                billboard: {
                    image: require("@/assets/image/gsjcimg/智慧门牌.png"),
                    width: 183,
                    height: 160,
                    disableDepthTestDistance: Number.POSITIVE_INFINITY,
                    scaleByDistance: new Cesium.NearFarScalar(0, 1, 5000, 0)
                }
            });
            //村干部
            window.Viewer.entities.add({
                id: "fh2",
                position: Cesium.Cartesian3.fromDegrees(
                    118.97909670352495, 28.875078311534093,
                    10
                ),
                billboard: {
                    image: require("@/assets/image/gsjcimg/智慧门牌.png"),
                    width: 183,
                    height: 160,
                    disableDepthTestDistance: Number.POSITIVE_INFINITY,
                    scaleByDistance: new Cesium.NearFarScalar(0, 1, 5000, 0)
                }
            });
        }

        //智慧门牌清除
        Vue.prototype.zhmpclear = function () {
            window.Viewer.entities.removeById("fh1");
            window.Viewer.entities.removeById("fh2");
        }
    }
}